<html>
<head><meta charset="utf-8"><title>const prop `Rvalue::Len` · t-compiler/wg-mir-opt · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/index.html">t-compiler/wg-mir-opt</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html">const prop `Rvalue::Len`</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="166270365"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166270365" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166270365">(May 22 2019 at 14:05)</a>:</h4>
<p>ooooh</p>



<a name="166270451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166270451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166270451">(May 22 2019 at 14:06)</a>:</h4>
<p>I think the main issue is some unimplemented <code>Place</code> handling in <code>eval_place</code></p>



<a name="166270471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166270471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166270471">(May 22 2019 at 14:06)</a>:</h4>
<p>unimplemented?</p>



<a name="166270478"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166270478" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166270478">(May 22 2019 at 14:06)</a>:</h4>
<p>Unhandled is probably a better term</p>



<a name="166270641"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166270641" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166270641">(May 22 2019 at 14:08)</a>:</h4>
<p>For example, <code>ProjectionElem::Deref</code> falls into this branch <a href="https://github.com/rust-lang/rust/blob/37ff5d388f8c004ca248adb635f1cc84d347eda0/src/librustc_mir/transform/const_prop.rs#L312" target="_blank" title="https://github.com/rust-lang/rust/blob/37ff5d388f8c004ca248adb635f1cc84d347eda0/src/librustc_mir/transform/const_prop.rs#L312">https://github.com/rust-lang/rust/blob/37ff5d388f8c004ca248adb635f1cc84d347eda0/src/librustc_mir/transform/const_prop.rs#L312</a></p>



<a name="166270743"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166270743" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166270743">(May 22 2019 at 14:09)</a>:</h4>
<p>oh. Hmm... I think we should be able to do even <code>Index</code>nowadays</p>



<a name="166270793"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166270793" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166270793">(May 22 2019 at 14:09)</a>:</h4>
<p>it would just be fairly unfun to do, maybe we can share more code with <code>InterpCx</code>, let's see</p>



<a name="166271128"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166271128" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166271128">(May 22 2019 at 14:12)</a>:</h4>
<p>hmmmmmm. evil idea: we can actually create the stackframe of the <code>InterpCx</code> used in const propagation and just treat all kinds of errors as "don't propagate"</p>



<a name="166271135"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166271135" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166271135">(May 22 2019 at 14:12)</a>:</h4>
<p>There's a comment about using <code>ecx.operand_projection()</code> but it seems to imply that doesn't work because we don't have a proper evaluation stack?</p>



<a name="166271152"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166271152" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166271152">(May 22 2019 at 14:12)</a>:</h4>
<p>Interesting</p>



<a name="166271156"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166271156" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166271156">(May 22 2019 at 14:12)</a>:</h4>
<p>yea, <code>InterpCx</code> has a fake <code>Frame</code></p>



<a name="166271175"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166271175" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166271175">(May 22 2019 at 14:13)</a>:</h4>
<p>fake meaning: no local variables</p>



<a name="166271191"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166271191" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166271191">(May 22 2019 at 14:13)</a>:</h4>
<p>but I mean, nowadays we are keeping around our own local variables</p>



<a name="166271196"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166271196" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166271196">(May 22 2019 at 14:13)</a>:</h4>
<p>Ok</p>



<a name="166271219"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166271219" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166271219">(May 22 2019 at 14:13)</a>:</h4>
<p>I haven't looked at it too closely</p>



<a name="166271232"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166271232" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166271232">(May 22 2019 at 14:13)</a>:</h4>
<p>but it may be an avenue we can go into in the future</p>



<a name="166271233"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166271233" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166271233">(May 22 2019 at 14:13)</a>:</h4>
<p>I'd started going down the path of implementing support for <code>Deref</code> and some other stuff but it was beginning to feel like I was just duplicating <code>operand_projection()</code></p>



<a name="166271270"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166271270" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166271270">(May 22 2019 at 14:14)</a>:</h4>
<p>for now, you are mainly missing <code>Deref</code> right now for <code>Len</code>?</p>



<a name="166271347"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166271347" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166271347">(May 22 2019 at 14:14)</a>:</h4>
<p>There's at least another <code>Place</code> case I need to implement as well. Something to do with the other <code>StaticKind</code>s <a href="https://github.com/rust-lang/rust/blob/37ff5d388f8c004ca248adb635f1cc84d347eda0/src/librustc_mir/transform/const_prop.rs#L315" target="_blank" title="https://github.com/rust-lang/rust/blob/37ff5d388f8c004ca248adb635f1cc84d347eda0/src/librustc_mir/transform/const_prop.rs#L315">https://github.com/rust-lang/rust/blob/37ff5d388f8c004ca248adb635f1cc84d347eda0/src/librustc_mir/transform/const_prop.rs#L315</a></p>



<a name="166271385"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166271385" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166271385">(May 22 2019 at 14:15)</a>:</h4>
<p>hmm... what happens if you just invoke <code>operand_projection</code>?</p>



<a name="166271506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166271506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166271506">(May 22 2019 at 14:16)</a>:</h4>
<p>oh that calls <code>ref_to_mplace</code></p>



<a name="166271519"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166271519" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166271519">(May 22 2019 at 14:16)</a>:</h4>
<p>not good</p>



<a name="166271609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166271609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166271609">(May 22 2019 at 14:17)</a>:</h4>
<p>Because it returns an <code>mplace</code> or because of const eval stuff?</p>



<a name="166271620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166271620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166271620">(May 22 2019 at 14:17)</a>:</h4>
<p>Sorry, miri is still kind of a black box to me</p>



<a name="166271903"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166271903" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166271903">(May 22 2019 at 14:20)</a>:</h4>
<p>yea, mplace would point into the local stack</p>



<a name="166271924"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166271924" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166271924">(May 22 2019 at 14:20)</a>:</h4>
<p>it may work out, but <code>InterpCx</code> is not setup to handle thsi</p>



<a name="166271928"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166271928" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166271928">(May 22 2019 at 14:20)</a>:</h4>
<p>*this</p>



<a name="166271932"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166271932" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166271932">(May 22 2019 at 14:20)</a>:</h4>
<p>so for now, feel free to create some duplication</p>



<a name="166271943"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166271943" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166271943">(May 22 2019 at 14:20)</a>:</h4>
<p>I'll look into merging miri and const prop</p>



<a name="166271979"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166271979" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166271979">(May 22 2019 at 14:21)</a>:</h4>
<p>Does the mplace stuff impact interpreting <code>Immediate</code>s? That's another thing on my list to add support for</p>



<a name="166272013"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166272013" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166272013">(May 22 2019 at 14:21)</a>:</h4>
<p>what do you mean by "interpreting"? like operations on <code>Immediate</code>?</p>



<a name="166272016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166272016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166272016">(May 22 2019 at 14:21)</a>:</h4>
<p>We hit that in <a href="#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/const.20propagation/near/165707831" title="#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/const.20propagation/near/165707831">https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/const.20propagation/near/165707831</a></p>



<a name="166272026"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166272026" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166272026">(May 22 2019 at 14:21)</a>:</h4>
<p>Yeah</p>



<a name="166272041"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166272041" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166272041">(May 22 2019 at 14:21)</a>:</h4>
<p>Const propagating I should say</p>



<a name="166273703"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166273703" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166273703">(May 22 2019 at 14:37)</a>:</h4>
<p>hmm</p>



<a name="166273709"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166273709" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166273709">(May 22 2019 at 14:37)</a>:</h4>
<p>ok, this may actually work</p>



<a name="166273715"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166273715" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166273715">(May 22 2019 at 14:37)</a>:</h4>
<p>even with the <code>mplace</code></p>



<a name="166273805"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166273805" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166273805">(May 22 2019 at 14:38)</a>:</h4>
<p>because if you input an <code>Immediate</code>, and it is a <code>Pointer</code>, then the <code>Allocation</code> exists, and we can read from it, never even looking at the stack</p>



<a name="166273847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166273847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166273847">(May 22 2019 at 14:38)</a>:</h4>
<p>so yea, just call <code>operand_projection</code></p>



<a name="166273945"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166273945" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166273945">(May 22 2019 at 14:39)</a>:</h4>
<p>Ok</p>



<a name="166274071"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166274071" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166274071">(May 22 2019 at 14:40)</a>:</h4>
<p>Thanks for your help btw, I really enjoy working in this part of the compiler! <span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>



<a name="166274333"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166274333" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166274333">(May 22 2019 at 14:42)</a>:</h4>
<p>and if you have an <code>Indirect</code> e.g. after casting, you should be able to <code>try_read_immediate</code></p>



<a name="166274393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166274393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166274393">(May 22 2019 at 14:43)</a>:</h4>
<p>great you like it! I think it's a fun part, too</p>



<a name="166726765"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166726765" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166726765">(May 28 2019 at 15:19)</a>:</h4>
<p>I'm going to close <a href="https://github.com/rust-lang/rust/issues/61081" target="_blank" title="https://github.com/rust-lang/rust/issues/61081">#61081</a> for now since:</p>
<p>1. The current implementation has some undesirable changes like the stuff to support statics and bare slices <br>
2. I don't see anyway to actually exercise the code that handles the <code>Len</code> operand and I don't think we should be adding dead code to the compiler<br>
However, I think <a href="https://github.com/rust-lang/rust/pull/61081#discussion_r287575415" target="_blank" title="https://github.com/rust-lang/rust/pull/61081#discussion_r287575415">this comment</a> about supporting propagation from <code>let</code> bindings has some potential so I'm going to play with that a bit.</p>



<a name="166789822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166789822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166789822">(May 29 2019 at 07:14)</a>:</h4>
<p>have you tried doing it all in one expressions so it'd all be temporaries? Like <code>(&amp;[5, 6] as &amp;[u8])[42]</code>?</p>



<a name="166806865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166806865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166806865">(May 29 2019 at 11:49)</a>:</h4>
<p>I tried that but <code>as</code> doesn't want to do the cast:</p>
<div class="codehilite"><pre><span></span>error[E0605]: non-primitive cast: `&amp;[i32; 2]` as `&amp;[u8]`
 --&gt; src/main.rs:3:13
  |
3 |     let x = (&amp;[5, 6] as &amp;[u8]);
  |             ^^^^^^^^^^^^^^^^^^
  |
  = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait
</pre></div>



<a name="166806986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166806986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166806986">(May 29 2019 at 11:51)</a>:</h4>
<p>oh well, inference strikes again</p>



<a name="166806994"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166806994" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166806994">(May 29 2019 at 11:51)</a>:</h4>
<p><code>&amp;[5, 6] as &amp;[i32]</code> or <code>&amp;[5u8, 6] as &amp;[u8]</code></p>



<a name="166807626"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166807626" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166807626">(May 29 2019 at 12:01)</a>:</h4>
<p>Ah ok</p>



<a name="166807637"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20%60Rvalue%3A%3ALen%60/near/166807637" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20.60Rvalue.3A.3ALen.60.html#166807637">(May 29 2019 at 12:01)</a>:</h4>
<p>I thought it was complaining because of the array -&gt; slice conversion</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>